package com.danielepelagatti.utils
{
	import com.danielepelagatti.flickrmanager.view.UploadList;
	
	import mx.core.UIComponent;
	import flash.utils.Dictionary;
	import mx.core.Container;
	/**
	 * 
	 * @author dpelagatti
	 * 
	 */	
	public class ViewLocator
	{
		/**
		* 
		*/		
		protected static var inst:ViewLocator;
        /**
         * 
         * @return 
         * 
         */		
        public static function getInstance():ViewLocator
        {
            if(inst == null)
            {
                inst = new ViewLocator();
            }
            return inst;
        }
        /**
         * 
         * @param id
         * @param view
         * 
         */        
        public function registerView(id:String,view:UIComponent):void
        {
        	var readdable:ReAddableView = new ReAddableView();
        	
        	readdable._view = view;
        	readdable._height = view.height;
        	readdable._width = view.width;
        	readdable._parent = view.parent;
        	readdable._parentIndex = view.parent.getChildIndex(view);
        	readdable._percentHeight = view.percentHeight;
        	readdable._percentWidth = view.percentWidth;
        	
        	registeredViews [ id ] = readdable;
        }
        /**
         * 
         * @param id
         * @return 
         * 
         */        
        public function getView(id:String):ReAddableView
        {
        	return registeredViews [ id ] as ReAddableView;
        }
        /**
        * 
        */        
        protected var registeredViews:Dictionary = new Dictionary();
	}
}